package com.sci.web.dao;

import java.util.List;

import com.jfinal.plugin.activerecord.Page;
import com.sci.web.model.genmodel.FileUploadfileinf;
import com.sci.web.util.StringUtil;

public class FileUploadfileinfDao extends FileUploadfileinf {
	
	  
	/**  
	* @Fields field:field:{todo}(用一句话描述这个变量表示什么)  
	*/  
	    
	private static final long serialVersionUID = 1L;
	public static final FileUploadfileinfDao me = new FileUploadfileinfDao();
	
	
	
	/**  
	* @Title: insertFileUploadfileinf  
	* @Description: 新增文件上传记录
	* @param @param fileUploadfileinf
	* @param @return
	* @Author LiuFei
	* @Date 2018年3月28日
	*/  
	public int insertFileUploadfileinf(FileUploadfileinf fileUploadfileinf){
		boolean save = fileUploadfileinf.save();
		return save==true?1:0;
	}
	
	
	
	/**  
	* @Title: updateFileUploadfileinf  
	* @Description: 修改文件上传记录
	* @param @param fileUploadfileinf
	* @param @return
	* @Author LiuFei
	* @Date 2018年3月28日
	*/  
	public int updateFileUploadfileinf(FileUploadfileinf fileUploadfileinf){
		boolean save = fileUploadfileinf.update();
		return save==true?1:0;
	}
	
	
	
	/**  
	* @Title: geetFileUploadfileinfAll  
	* @Description: 获取所有文件
	* @param @return
	* @Author LiuFei
	* @Date 2018年3月28日
	*/  
	public List<FileUploadfileinf> geetFileUploadfileinfAll(){
		String sql = " select * from "+FileUploadfileinf.tableName + " order by update_time desc ";
		return dao.find(sql);
	}
	
	
	
	public FileUploadfileinf geetFileUploadfileinfById(String id){
		return dao.findById(id);
	}
	
	
	public Page<FileUploadfileinf> geetFileUploadfileinfPageInate(int pageNumber , int pageSize , 
			String searchStr , String fileType ){
		String selectStr = " select * ";
		String whereStr = " from "+FileUploadfileinf.tableName +" where 1=1";
		if(StringUtil.isNotEmpty(searchStr)){
			whereStr += " and  ";
			whereStr += " (";
			whereStr += " File_Show_Name like '%"+searchStr+"%'";
			whereStr += " OR File_Name like '%"+searchStr+"%'";
			whereStr += " OR Note_persion like '%"+searchStr+"%'";
			whereStr +=")  ";
		}
		if(StringUtil.isNotEmpty(fileType)){
			whereStr += " and Expand_name like '%"+fileType+"%' ";
		}
		return dao.paginate(pageNumber, pageSize, selectStr, whereStr);
		
	}
	
	
	
	

	

}
